package exam.web.action;

import exam.business.service.SubQuestionAddService;
import exam.common.key.KeySubQuestion;
import exam.common.util.NullCheckUtil;
import exam.model.entity.TSubQuestionEntity;
import exam.web.action.base.SubQuestionActionBase;
/**
 * <p>AddSubQuestionAction</p>
 * <br>
 * <p>Action: Thêm danh mục câu hỏi</p>
 * 
 * @author Phong
 * @version (create: 10/5/2012) (update: 20/5/2012)
 */
public class AddSubQuestionAction extends SubQuestionActionBase {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public String execute() throws Exception {
		String port = null;
		String btAdd = request.getParameter("btAdd");
		if(NullCheckUtil.isNull(btAdd)) {
			port = INPUT;
		} else {
			TSubQuestionEntity tSubQuestionEntity = new TSubQuestionEntity();
			// copy thuoc tinh
			copyToTSubQuestionEntity(tSubQuestionEntity);
			// put tSubQuestionEntity vao serviceInfo
			serviceInfo.put(KeySubQuestion.T_SUB_QUESTION_ENTITY, tSubQuestionEntity);
			// yeu cau them danh muc cau hoi
			SubQuestionAddService subQuestionAddService = new SubQuestionAddService();
			port = subQuestionAddService.executeService(serviceInfo);
			if(FAIL.equals(port)) {
				addActionError("Thêm danh mục câu hỏi thất bại");
			} else {
				addActionMessage("Thêm danh mục câu hỏi thành công");
			}
		}
		return port;
	}
}
